﻿using DreamCMS.BLL;
using DreamCMS.Entity;
using DreamCMS.Web.Admin;
using DreamCMS.WebCore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DreamCMS.Web.admin.CatMgr
{
    /// <summary>
    /// UpdateCat 的摘要说明
    /// </summary>
    public class UpdateCat : AdminPageBase,IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            long catid = RequestHelper.QueryInt("catid", 0);
            string newname = RequestHelper.GetQueryString("newname", true);
            CategoryInfo cat=CategoryManager.GetCatById(catid);
            if(cat!=null && !string.IsNullOrEmpty(newname))
            {
                if(CategoryManager.IsExistName(newname))
                {
                    HttpContext.Current.Response.Write("Has");
                    return;
                }
                cat.Name = newname;
                CategoryManager.UpdateCategory(cat);
                return;
            }
            else
            {
                HttpContext.Current.Response.Write("Error");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}